home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / Kernel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-15  |  7.7 KB  |  282 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Kernel.h
  3.  
  4.      Contains:    Kernel Interfaces
  5.  
  6.      Version:    Technology:    PowerSurge 1.0.2.
  7.                  Package:    Universal Interfaces 2.1.2 on ETO #20
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __KERNEL__
  21. #define __KERNEL__
  22.  
  23.  
  24. #ifndef __ERRORS__
  25. #include <Errors.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __TYPES__
  30. #include <Types.h>
  31. #endif
  32.  
  33. #ifndef __MACHINEEXCEPTIONS__
  34. #include <MachineExceptions.h>
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_ALIGN_SUPPORTED
  42. #pragma options align=mac68k
  43. #endif
  44.  
  45. #if PRAGMA_IMPORT_SUPPORTED
  46. #pragma import on
  47. #endif
  48.  
  49. typedef KernelID AddressSpaceID, TimerID, IOPreparationID, TaskID, SoftwareInterruptID;
  50.  
  51. /* OrderedItems*/
  52. /**/
  53. /* This should move to a more appropriate place in the future.*/
  54. typedef OSType OrderedItemService;
  55.  
  56. typedef OSType OrderedItemSignature;
  57.  
  58.  
  59. enum {
  60.     kMatchAnyOrderedItemService    = (OrderedItemService)'****',
  61.     kMatchAnyOrderedItemSignature = (OrderedItemSignature)'****',
  62.     kDoNotMatchAnyOrderedItemService = (OrderedItemService)'----',
  63.     kDoNotMatchAnyOrderedItemSignature = (OrderedItemSignature)'----'
  64. };
  65.  
  66. struct OrderedItemName {
  67.     OrderedItemService                service;
  68.     OrderedItemSignature            signature;
  69. };
  70. typedef struct OrderedItemName OrderedItemName, *OrderedItemNamePtr;
  71.  
  72. typedef OptionBits OrderedItemOptions;
  73.  
  74.  
  75. enum {
  76.     kOrderedItemIsRightBefore    = 0x00000001,
  77.     kOrderedItemIsRightAfter    = 0x00000002
  78. };
  79.  
  80. struct OrderRequirements {
  81.     OrderedItemOptions                options;
  82.     OrderedItemName                    itemBefore;
  83.     OrderedItemName                    itemAfter;
  84. };
  85. typedef struct OrderRequirements OrderRequirements, *OrderRequirementsPtr;
  86.  
  87. /* Tasking*/
  88. typedef UInt32 ExecutionLevel;
  89.  
  90.  
  91. enum {
  92.     kTaskLevel                    = 0,
  93.     kSoftwareInterruptLevel        = 1,
  94.     kAcceptFunctionLevel        = 2,
  95.     kKernelLevel                = 3,
  96.     kSIHAcceptFunctionLevel        = 4,
  97.     kSecondaryInterruptLevel    = 5,
  98.     kHardwareInterruptLevel        = 6
  99. };
  100.  
  101. typedef void (*SoftwareInterruptHandler)(void *p1, void *p2);
  102. typedef OSStatus (*SecondaryInterruptHandler2)(void *p1, void *p2);
  103. /* Memory System basics*/
  104.  
  105. enum {
  106.     kNoAreaID                    = 0
  107. };
  108.  
  109. #define kCurrentAddressSpaceID ((AddressSpaceID) -1)
  110. struct LogicalAddressRange {
  111.     LogicalAddress                    address;
  112.     ByteCount                        count;
  113. };
  114. typedef struct LogicalAddressRange LogicalAddressRange, *LogicalAddressRangePtr;
  115.  
  116. struct PhysicalAddressRange {
  117.     PhysicalAddress                    address;
  118.     ByteCount                        count;
  119. };
  120. typedef struct PhysicalAddressRange PhysicalAddressRange, *PhysicalAddressRangePtr;
  121.  
  122. /* For PrepareMemoryForIO and CheckpointIO*/
  123. typedef OptionBits IOPreparationOptions;
  124.  
  125.  
  126. enum {
  127.     kIOMultipleRanges            = 0x00000001,
  128.     kIOLogicalRanges            = 0x00000002,
  129.     kIOMinimalLogicalMapping    = 0x00000004,
  130.     kIOShareMappingTables        = 0x00000008,
  131.     kIOIsInput                    = 0x00000010,
  132.     kIOIsOutput                    = 0x00000020,
  133.     kIOCoherentDataPath            = 0x00000040,
  134.     kIOTransferIsLogical        = 0x00000080,
  135.     kIOClientIsUserMode            = 0x00000080
  136. };
  137.  
  138. typedef OptionBits IOPreparationState;
  139.  
  140.  
  141. enum {
  142.     kIOStateDone                = 0x00000001
  143. };
  144.  
  145. enum {
  146.     kInvalidPageAddress            = (-1)
  147. };
  148.  
  149. struct AddressRange {
  150.     void                            *base;
  151.     ByteCount                        length;
  152. };
  153. typedef struct AddressRange AddressRange;
  154.  
  155. /* C's treatment of arrays and array pointers is atypical*/
  156. typedef LogicalAddress *LogicalMappingTablePtr;
  157.  
  158. typedef PhysicalAddress *PhysicalMappingTablePtr;
  159.  
  160. typedef struct AddressRange *AddressRangeTablePtr;
  161.  
  162. struct MultipleAddressRange {
  163.     ItemCount                        entryCount;
  164.     AddressRangeTablePtr            rangeTable;
  165. };
  166. typedef struct MultipleAddressRange MultipleAddressRange;
  167.  
  168. /* Separate C definition so that union has a name.  A future version of the interfacer*/
  169. /* tool will allow a name (that gets thrown out in Pascal and Asm).*/
  170. struct IOPreparationTable {
  171.     IOPreparationOptions            options;
  172.     IOPreparationState                state;
  173.     IOPreparationID                    preparationID;
  174.     AddressSpaceID                    addressSpace;
  175.     ByteCount                        granularity;
  176.     ByteCount                        firstPrepared;
  177.     ByteCount                        lengthPrepared;
  178.     ItemCount                        mappingEntryCount;
  179.     LogicalMappingTablePtr            logicalMapping;
  180.     PhysicalMappingTablePtr            physicalMapping;
  181.     union {
  182.         AddressRange                    range;
  183.         MultipleAddressRange            multipleRanges;
  184.     }                                rangeInfo;
  185. };
  186. typedef struct IOPreparationTable IOPreparationTable;
  187.  
  188. typedef OptionBits IOCheckpointOptions;
  189.  
  190.  
  191. enum {
  192.     kNextIOIsInput                = 0x00000001,
  193.     kNextIOIsOutput                = 0x00000002,
  194.     kMoreIOTransfers            = 0x00000004
  195. };
  196.  
  197. /* For SetProcessorCacheMode*/
  198. typedef UInt32 ProcessorCacheMode;
  199.  
  200.  
  201. enum {
  202.     kProcessorCacheModeDefault    = 0,
  203.     kProcessorCacheModeInhibited = 1,
  204.     kProcessorCacheModeWriteThrough = 2,
  205.     kProcessorCacheModeCopyBack    = 3
  206. };
  207.  
  208. /* For GetPageInformation and UnmapMemory*/
  209. enum {
  210.     kPageInformationVersion        = 0
  211. };
  212.  
  213. typedef UInt32 PageStateInformation;
  214.  
  215.  
  216. enum {
  217.     kPageIsProtected            = 0x00000001,
  218.     kPageIsProtectedPrivileged    = 0x00000002,
  219.     kPageIsModified                = 0x00000004,
  220.     kPageIsReferenced            = 0x00000008,
  221.     kPageIsLocked                = 0x00000010,
  222.     kPageIsResident                = 0x00000020,
  223.     kPageIsShared                = 0x00000040,
  224.     kPageIsWriteThroughCached    = 0x00000080,
  225.     kPageIsCopyBackCached        = 0x00000100
  226. };
  227.  
  228. struct PageInformation {
  229.     AreaID                            area;
  230.     ItemCount                        count;
  231.     PageStateInformation            information[1];
  232. };
  233. typedef struct PageInformation PageInformation, *PageInformationPtr;
  234.  
  235. typedef UInt32 IteratorKey;
  236.  
  237. /*  Hardware Interrupt related declarations  */
  238. typedef UInt32 InterruptVector;
  239.  
  240. typedef void (*InterruptVectorHandler)(InterruptVector theVector, void *theParameter);
  241. extern ExecutionLevel CurrentExecutionLevel(void);
  242. extern TaskID CurrentTaskID(void);
  243. extern OSStatus DelayFor(Duration expirationTime);
  244. /*  Software Interrupts  */
  245. extern OSStatus CreateSoftwareInterrupt(SoftwareInterruptHandler handler, TaskID task, const void *p1, Boolean persistent, SoftwareInterruptID *softwareInterrupt);
  246. extern OSStatus SendSoftwareInterrupt(SoftwareInterruptID softwareInterrupt, const void *p2);
  247. extern OSStatus DeleteSoftwareInterrupt(SoftwareInterruptID softwareInterrupt);
  248. extern void RunSoftwareInterrupts(void);
  249. /*  Secondary Interrupts  */
  250. extern OSStatus CallSecondaryInterruptHandler2(SecondaryInterruptHandler2 handler, ExceptionHandler exceptionHandler, const void *p1, const void *p2);
  251. extern OSStatus QueueSecondaryInterruptHandler(SecondaryInterruptHandler2 handler, ExceptionHandler exceptionHandler, const void *p1, const void *p2);
  252. /*  Timers  */
  253. extern OSStatus SetInterruptTimer(const AbsoluteTime *expirationTime, SecondaryInterruptHandler2 handler, const void *p1, TimerID *timer);
  254. extern OSStatus CancelTimer(TimerID timer, AbsoluteTime *timeRemaining);
  255. /*  IO related Operations  */
  256. extern OSStatus PrepareMemoryForIO(IOPreparationTable *theIOPreparationTable);
  257. extern OSStatus CheckpointIO(IOPreparationID thePreparationID, IOCheckpointOptions theOptions);
  258. /*  Memory Operations  */
  259. extern OSStatus GetPageInformation(AddressSpaceID theAddressSpace, LogicalAddress theBase, ByteCount theLength, PBVersion theVersion, PageInformation *thePageInfo);
  260. /*  Processor Cache Related  */
  261. extern OSStatus SetProcessorCacheMode(AddressSpaceID theAddressSpace, void *theBase, ByteCount theLength, ProcessorCacheMode theMode);
  262. /*  Debugging  */
  263. extern void SysDebug(void);
  264. extern void SysDebugStr(StringPtr str);
  265. /*  Hardware Interrupts  */
  266. extern OSStatus InstallInterruptVectorHandler(InterruptVector theVector, InterruptVectorHandler theHandler, ExceptionHandler theExceptionHandler, const void *theParameter1);
  267. extern OSStatus RemoveInterruptVectorHandler(InterruptVector theVector, InterruptVectorHandler theHandler);
  268.  
  269. #if PRAGMA_IMPORT_SUPPORTED
  270. #pragma import off
  271. #endif
  272.  
  273. #if PRAGMA_ALIGN_SUPPORTED
  274. #pragma options align=reset
  275. #endif
  276.  
  277. #ifdef __cplusplus
  278. }
  279. #endif
  280.  
  281. #endif /* __KERNEL__ */
  282.